package com.area.cth.config;

import com.area.cth.interceptors.LoginAdminInterceptors;
import com.area.cth.interceptors.LoginInterceptors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptors li;
    @Autowired
    private LoginAdminInterceptors loginAdminInterceptors;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(li)
                .excludePathPatterns("/user/register", "/user/login", "/admin/**")
                .excludePathPatterns("/doc.html", "/webjars/**", "/v3/api-docs/**", "/swagger-ui.html");

        registry.addInterceptor(loginAdminInterceptors)
                .addPathPatterns("/admin/**")
                .excludePathPatterns("/doc.html", "/webjars/**", "/v3/api-docs/**", "/swagger-ui.html");
    }
}
